package com.doget.data.delete;

import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.ParcelUuid;
import android.util.Log;

public class BlueToothFoundReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
//        RDL52810==getAddress==FA:0F:B9:A0:59:5C==getAlias==null==getType==2==getUuids==null
//        RDL52810==getAddress==C1:BD:D1:76:37:11==getAlias==null==getType==2==getUuids==null


        //获取广播Action
        String action = intent.getAction();
        //判断广播是搜索到设备还是搜索完成
        if (BluetoothDevice.ACTION_FOUND.equals(action)) {
            // 找到设备后获取其设备
            BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
            Log.i("扫描到了", device.getName() + "==getAddress==" + device.getAddress()
                    + "==getAlias==" + device.getAlias()
                    + "==getType==" + device.getType()
                    + "==getUuids==" + device.getUuids());
            ParcelUuid[] uuids = device.getUuids();
            if (null != uuids && uuids.length >= 1) {
                for (ParcelUuid uuid : uuids) {
                    Log.i("uuid扫描到了", device.getName()
                            + "==getUuids==" + uuid.toString());
                }
            }
        } else if (action.equals(BluetoothAdapter.ACTION_DISCOVERY_STARTED)) {
            Log.i("扫描到了", "搜索开启");
        } else if (action.equals(BluetoothAdapter.ACTION_DISCOVERY_FINISHED)) {
            Log.i("扫描到了", "搜索完成");
        }
    }
}